/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.amazon.node;

/**
 *
 * @author Salman Noor, Shcool of Electrical and Information Engineering
 * @Copyright: Wits University 2013 - All Rights Reserved
 * @email salmannoor74415@gmail.com
 * @License BSD License (http://www.linfo.org/bsdlicense.html)
 */
public class Number extends Node {

    public Number(String number) throws InstantiationException {
        if (!number.matches("^[0-9]+$")){
            throw new InstantiationException(number +" is not a valid number");
        }
        super.nodeValue = number;
    }       
     
    @Override
    public String getValue(){
        return super.nodeValue;
    }

    @Override
    public void setValue(String value) {
        super.nodeValue = value;
    }
    
    @Override
    public Integer evaluate(){
        return Integer.parseInt(super.nodeValue);
    }

}
